package com.rc.saas.tenant.service.area;

import com.rc.saas.tenant.mapper.area.PlatformAreaMapper;
import com.rc.saas.tenant.mapper.area.PlatformCityMapper;
import com.rc.saas.tenant.mapper.area.PlatformProvinceMapper;
import com.rc.saas.tenant.model.area.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by sven on 2018-04-17
 */
@Service
public class PlatformAreaServiceImpl implements PlatformAreaService {
    @Autowired
    private PlatformAreaMapper platformAreaMapper;

    @Autowired
    private PlatformProvinceMapper platformProvinceMapper;


    @Autowired
    private PlatformCityMapper platformCityMapper;

    @Override
    public PlatformAreaMapper getMapper() {
        return platformAreaMapper;
    }

    @Override
    public List<PlatformProvince> listAllProvince() {
        PlatformProvinceExample example = new PlatformProvinceExample();
        List<PlatformProvince> platformProvinces = platformProvinceMapper.selectByExample(example);
        return platformProvinces;
    }

    @Override
    public List<PlatformArea> listAreaByCityId(String cityId) {
        PlatformAreaExample example = new PlatformAreaExample();
        example.createCriteria().andCityIdEqualTo(cityId);
        List<PlatformArea> platformAreas = platformAreaMapper.selectByExample(example);
        return platformAreas;
    }

    @Override
    public List<PlatformCity> listCityByProvinceId(String provinceId) {
        PlatformCityExample example = new PlatformCityExample();
        example.createCriteria().andProvinceIdEqualTo(provinceId);
        return platformCityMapper.selectByExample(example);
    }
}
